package subject_set.lanqiao.moli;

import java.util.Scanner;

/**
 * @author haomin
 * @date 2022/11/06 09:21
 **/
public class Num6 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextLine()){
            int first = Integer.parseInt(s.nextLine());
            int second = Integer.parseInt(s.nextLine());

            if(first <= second){
                System.out.println(second - first);
            }else{
                System.out.println((7-first) + (second));
            }
        }
    }
}